#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100;
int minlen[maxn][maxn][maxn];
char a[maxn],b[maxn],c[maxn];
void print(int na,int nb,int nc)
{
    if(na<0||nb<0||nc<0) return;
    //依据dp时的路径进行回溯
    if(a[na]==b[nb]&&a[na]==c[nc])   //a、b和c对应位置均相等
    {
        print(na-1,nb-1,nc-1);
        cout<<a[na];
    }
    else if(a[na]==b[nb]&&minlen[na][nb][nc]==minlen[na-1][nb-1][nc]+1)   //a和b对应位置均相等
    {
        print(na-1,nb-1,nc);
        cout<<a[na];
    }
    else if(a[na]==c[nc]&&minlen[na][nb][nc]==minlen[na-1][nb][nc-1]+1)   //a和c对应位置均相等
    {
        print(na-1,nb,nc-1);
        cout<<a[na];
    }
    else if(c[nc]==b[nb]&&minlen[na][nb][nc]==minlen[na][nb-1][nc-1]+1)   //b和c对应位置均相等
    {
        print(na,nb-1,nc-1);
        cout<<c[nc];
    }
    else {          ////a、b和c对应位置均不相等
        if(minlen[na][nb][nc]==minlen[na][nb][nc-1]+1)
        {
            print(na,nb,nc-1);
            cout<<c[nc];
        }
        else if(minlen[na][nb][nc]==minlen[na][nb-1][nc]+1)
        {
            print(na,nb-1,nc);
            cout<<b[nb];
        }
        else if(minlen[na][nb][nc]==minlen[na-1][nb][nc]+1)
        {
            print(na-1,nb,nc);
            cout<<a[na];
        }
    }
}
int main()
{
    a[0]='*';b[0]='+';c[0]='-';
    cin>>a+1>>b+1>>c+1;
    memset(minlen,0x3f,sizeof(minlen));
    minlen[0][0][0]=0;
    int na=strlen(a+1),nb=strlen(b+1),nc=strlen(c+1);
    for(int i=0;i<=na;i++)
    {
        for(int j=0;j<=nb;j++)
        {
            for(int k=0;k<=nc;k++)
            {
                if(a[i]==b[j]&&b[j]==c[k])    //a、b和c对应位置均相等
                minlen[i][j][k]=minlen[i-1][j-1][k-1]+1;
                else if(a[i]==b[j])           //a和b对应位置均相等
                minlen[i][j][k]=minlen[i-1][j-1][k]+1;
                else if(a[i]==c[k])           //a和c对应位置均相等
                minlen[i][j][k]=minlen[i-1][j][k-1]+1;
                else if(b[j]==c[k])           //b和c对应位置均相等
                minlen[i][j][k]=minlen[i][j-1][k-1]+1;
                if(i>0)
                minlen[i][j][k]=min(minlen[i-1][j][k]+1,minlen[i][j][k]);
                if(j>0)
                minlen[i][j][k]=min(minlen[i][j-1][k]+1,minlen[i][j][k]);
                if(k>0)
                minlen[i][j][k]=min(minlen[i][j][k-1]+1,minlen[i][j][k]);
            }
        }
    }
    cout<<"Length: "<<minlen[na][nb][nc]<<endl;
    cout<<"Shortest sequece: ";
    print(na,nb,nc);
}





